package com.mmall.concurrency.example.threadlocal;

public class RequestHolder {

    // final 要写在static前面，规范
    private final static ThreadLocal<Long> requestHolder = new ThreadLocal<>();

    public static void add(Long id){
        requestHolder.set(id);
    }

    public static Long getId(){
        return requestHolder.get();
    }
    // 如果不提供remove方法，不remove，只能等项目重新启动的时候这个变量才能被释放
    public static void remove(){
        requestHolder.remove();
    }
}
